package com.synjones.zeus.model.ykt.pay;

import com.synjones.core.bean.TimePattern;
import com.synjones.core.util.DateUtil;
import com.synjones.core.util.StringUtil;
import lombok.Data;
import sun.swing.StringUIClientPropertyKey;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;

import static com.synjones.zeus.model.CodeStr.STATUS_ALL_CODE;

/**
 * 流水接口app的请求bean
 * Created by liubinqiang on 2018/4/22.
 */
public class RecoreInfoAppReqBean {

    private String sno;
    private String mealType;
    private String state;
    private String beginDate;
    private String endDate;
    private int pageIndex;
    private int pageSize;

    public String getNextDate(String dateStr) {
        if (!StringUtil.isNullOrEmpty(dateStr)) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
                Date date = sdf.parse(dateStr);
                Calendar c = Calendar.getInstance();
                c.setTime(date);
                c.add(Calendar.DATE, 1);
                return sdf.format(c.getTime());
            } catch (Exception ex) {

            }
        }
        return dateStr;
    }

    public String getSno() {
        return sno;
    }

    public void setSno(String sno) {
        this.sno = sno;
    }

    public String getMealType() {
        if (StringUtil.isNullOrEmpty(mealType)) {
            return STATUS_ALL_CODE;
        }
        return mealType;
    }

    public void setMealType(String mealType) {
        this.mealType = mealType;
    }

    public String getState() {
        if (StringUtil.isNullOrEmpty(state)) {
            return STATUS_ALL_CODE;
        }
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getBeginDate() {
        if (StringUtil.isNullOrEmpty(this.beginDate)) {
            return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
        }
        return beginDate;
    }

    public void setBeginDate(String beginDate) {
        this.beginDate = beginDate;
    }

    public String getEndDate() {
        if (StringUtil.isNullOrEmpty(this.endDate)) {
            return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
        }
        return this.endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
